/**
 * File: BitUtil.java
 * Created by: mhaimel
 * Created on: Apr 30, 2010
 * CVS:  $Id: BitUtil.java 1.0 Apr 30, 2010 10:16:04 AM mhaimel Exp $
 */
package uk.ac.ebi.curtain.utils;

/**
 * @author mhaimel
 *
 */
public class BitUtil {
	
	public static boolean hasFlag(int val, int flag){
		if((val & flag) == flag){
			return true;
		} 
		return false;
	}
	
	public static int removeFlag(int val, int flag) {
		if(hasFlag(val, flag)){
			return flipFlag(val,flag);
		}
		return val;
	}
	
	public static int flipFlag(int val, int flag) {
		return val ^ flag;
	}
	
	public static int setFlag(int val, int flag) {
		return val | flag;
	}
}
